<extend name="work/base" />
<block name="content">
    <div class="data-list" data-url="{:url('lists')}">
        <form class="layui-form inline-form">
            <div class="pull-left">
                <div class="layui-inline">
                    <button class="layui-btn layui-btn-normal layui-btn-sm  ajax-form" data-url="{:url('add')}" title="添加用户"><i class="layui-icon">&#xe61f;</i> 添加用户</button>
                </div>
            </div>
        </form>
        <table class="layui-table text-center" id="list" lay-filter="list" list-url="{:url('lists')}" edit-url="{:url('edit')}" del-url="{:url('delete')}"></table>
    </div>
</block>
<block name="script">
    <script type="text/html" id="barDemo">
        <a class="layui-btn  layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
    </script>
    <script type="text/html" id="status">
        <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="正常|禁用" lay-filter="is_member" {{ d.status ==1?'checked' : '' }}>
    </script>
    <script type="text/javascript">
        layui.use([ 'element', 'table'], function(){
            var table = layui.table;
            table.render({
                elem: '#list'
                ,url:"{:Url('lists')}"
                ,toolbar: '<div></div>'
                ,page:true
                ,loading:true
                ,title:'用户表'
                ,limit:20
                ,defaultToolbar: ['filter', 'print', 'exports']
                ,cols: [[
                    {field:'username', width:160, title: '登录名', edit: 'text'}
                    ,{field:'nickname', width:160, title: '姓名' ,edit: 'text'}
                    ,{field:'openid', width:160, title: '绑定微信' }
                    ,{field:'group_name', width:160, title: '角色'}
                    ,{field:'login_times', width:100, title: '登陆次数', }
                    ,{field:'last_login_time', width:130, title: '上次登陆时间',templet: "<div>{{layui.util.toDateString(d.last_login_time*1000, 'yyyy-MM-dd')}}</div>"}
                    ,{field:'last_login_ip', width:130, title: '上次登陆IP', }
                    ,{field:'create_time', width:130, title: '注册时间', templet: "<div>{{layui.util.toDateString(d.create_time*1000, 'yyyy-MM-dd')}}</div>"}
                    ,{field:'status', width:100, title: '禁用/正常', templet:'#status'}
                    ,{field:'info',  title: '备注', edit: 'text'}
                    ,{fixed: 'right', width:115,title:'操作',  toolbar:'#barDemo'}
                ]]
            });
        });
    </script>



</block>
</block>